const { Tool, API, Event, Storage} = global.$util
Page({
  data: {
    phone: '',
  },
  onLoad: function (options) {
    const userInfo = Storage.getUserAccountInfo()
    console.log(userInfo);
    this.setData({
      oldCode: options.code
    })
  },
  //下一步
  submit() {
    if (Tool.isEmptyStr(this.data.phone)){
      Tool.showToast("手机号不能为空");
      return
    }
    if (!Tool.checkPhone(this.data.phone)) {
        Tool.showToast("请输入正确的手机号");
        return
    }
    const userInfo = Storage.getUserAccountInfo()
    console.log(userInfo);
    
    let params = {
      sex: '2',
      userName: 'cc',
      mobile: this.data.phone,
    }
    API.updateUserInfo(params).then((res) => {
      // let infos = Storage.getUserAccountInfo()
      // infos.phone = this.data.phone
      // Storage.setUserAccountInfo(infos)
      Tool.switchTab('/pages/mine/mine')
    }).catch((res) => {
      console.error(res)
    })
  },
  
  changePhone(e) {
      this.setData({
          phone: e.detail.value
      })
  },
})
